home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Booting Gallery / Booting Gallery (source) / (Libraries) / Fluent Libraries / Utils / EnsureAtomic.h < prev    next >
Encoding:
Text File  |  1996-06-22  |  517 b   |  36 lines  |  [TEXT/BROW]

  1. // EnsureAtomic.h
  2. // Created by Bill Hubauer on Mon, May 22, 1995 @ 6:56 AM.
  3.  
  4. #ifndef __EnsureAtomic__
  5. #define __EnsureAtomic__
  6.  
  7.  
  8. static short asm DisableInterupts()
  9. {
  10.     move.w SR,d0
  11.     ori.w #0x0700,SR
  12.     rts
  13. }
  14.  
  15. #pragma parameter  EnableInterupts(__D0)
  16. static void asm EnableInterupts(short saveSR)
  17. {
  18.     move.w d0,-(a7)
  19.     move.w (a7)+,SR
  20.     rts
  21. }
  22.  
  23.  
  24. class EnsureAtomic
  25. {
  26. public:
  27.     EnsureAtomic()                    {_saveSR = DisableInterupts();}
  28.     virtual ~EnsureAtomic()            {EnableInterupts(_saveSR);}
  29.     
  30.     
  31. private:
  32.     short        _saveSR;
  33. };
  34.  
  35. #endif
  36.